﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GWModflow.FileLayers
{
   public   class PGeneralHeadBoundary:Package
    {

       public PGeneralHeadBoundary()
       {

           this._fileType = FileType.GHB;

           this._generalHeads = new List<SPGeneralHead>();

           this.Fname = "solution.ghb";

           this.Nunit=44;


       }

       int _MXACTB;

       /// <summary>
       /// 活动gh最大个数
       /// </summary>
       public int MXACTB
       {
           get { return _MXACTB; }
           set { _MXACTB = value; }
       }


       int _IGHBCB = 104;

       public int IGHBCB
       {
           get { return _IGHBCB; }
           set { _IGHBCB = value; }
       }



       List<SPGeneralHead> _generalHeads;

       public List<SPGeneralHead> GeneralHeads
       {
           get { return _generalHeads; }

           
       }


       public override void WriteFile(string path)
       {
           string content = "# HuanAnKeJi CHD File" + "\r\n";
           content += string.Format("{0,10}", this.MXACTB) + " " + string.Format("{0,10}", this.IGHBCB) + "\r\n";

           string str = "";
           for (int i = 0; i < this.GeneralHeads.Count; i++)
           {
               str += string.Format("{0,10}", this.GeneralHeads[i].ITMP) + " " + string.Format("{0,10}", this.GeneralHeads[i].NP) + "\r\n";
               if (this.GeneralHeads[i].ITMP >= 0)
               {
                   for (int j = 0; j < this.GeneralHeads[i].GeneralData.Count; j++)
                   {
                       str += string.Format("{0,10}", this.GeneralHeads[i].GeneralData[j].Layer) + " " + string.Format("{0,10}", this.GeneralHeads[i].GeneralData[j].Row) + " " +
                              string.Format("{0,10}", this.GeneralHeads[i].GeneralData[j].Column) + " " + string.Format("{0,10}", this.GeneralHeads[i].GeneralData[j].Value) + " " +
                               string.Format("{0,10}", this.GeneralHeads[i].GeneralData[j].Value2)  + "\r\n";// +string.Format("{0,10}", this.GeneralHeads[i].GeneralData[j].Value3) + "\r\n";
                   }
               }
           }
           content +=str ;


           string fname = path + this.Fname;
           FXnaInfrastructure.FileHelper.WriteFile(fname, content);

       }


    }
}
